package cn.iocoder.yudao.module.member.controller.admin.companytemplate;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.member.controller.admin.companytemplate.vo.CompanyTemplateAuditReqVo;
import cn.iocoder.yudao.module.member.controller.app.companytemplate.vo.CompanyTemplatePageReqVO;
import cn.iocoder.yudao.module.member.controller.app.companytemplate.vo.CompanyTemplateRespVO;
import cn.iocoder.yudao.module.member.dal.dataobject.companytemplate.CompanyTemplateDO;
import cn.iocoder.yudao.module.member.service.companytemplate.CompanyTemplateService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 会员公司信息模板")
@RestController
@RequestMapping("/member/company-template")
@Validated
public class CompanyTemplateController {

    @Resource
    private CompanyTemplateService companyTemplateService;

    @GetMapping("/page")
    @Operation(summary = "获得会员公司信息模板待审核分页")
    public CommonResult<PageResult<CompanyTemplateRespVO>> getCompanyTemplatePage(@Valid CompanyTemplatePageReqVO pageReqVO) {
        PageResult<CompanyTemplateDO> pageResult = companyTemplateService.getCompanyTemplatePage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, CompanyTemplateRespVO.class));
    }


    @PostMapping("/audit")
    @Operation(summary = "审核会员公司信息模板")
    @Parameter(name = "id", description = "编号", required = true)
    public CommonResult<Boolean> auditCompanyTemplate(@RequestBody CompanyTemplateAuditReqVo reqVo) {
        companyTemplateService.auditCompanyTemplate(reqVo);
        return success(true);
    }

}
